package com.glut.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.glut.mapper.LevKldMapper;
import com.glut.service.LevKldService;
import com.glut.vo.LevKld;
import com.glut.vo.SecKld;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:沈林玉
 * @date:2020/2/9 15:23
 * @Description:
 */
@Service("levKldService")
public class LevKldServiceImpl implements LevKldService {

    @Autowired
    private LevKldMapper levKldMapper;

    /**
     * 1.查询一级知识点总记录数
     * @param levKld
     * @return
     */
    @Override
    public int selectLevKldCount( LevKld levKld, int pageNum, int pageSize) {
        return levKldMapper.selectLevKldCount(levKld,pageNum,pageSize);
    }

    /**
     * 2.查询二级知识点总记录数
     * @param secKld
     * @return
     */
    @Override
    public int selectSecKldCount(SecKld secKld) {
        return levKldMapper.selectSecKldCount(secKld);
    }

    /**
     * 1.根据一级知识点名查询其ID
     * @param levKld
     * @return
     */
    @Override
    public String selectLevKldIDByName(LevKld levKld) {
        return levKldMapper.selectLevKldIDByName(levKld);
    }

    /**
     * 2.根据一级知识点以及二级知识点名查询其ID
     * @param secKld
     * @return
     */
    @Override
    public String selectSecKldIDByName(SecKld secKld) {
        return levKldMapper.selectSecKldIDByName(secKld);
    }

    /**
     * 3.根据二级知识点ID查询其名
     * @param secKld
     * @return
     */
    @Override
    public String selectSecKldIDByID(SecKld secKld) {
        return levKldMapper.selectSecKldIDByID(secKld);
    }

    /**
     * 1.查询所有一级知识点分类
     * @return
     */
    @Override
    public Page<LevKld> selectAllLevKld(LevKld levKld, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return levKldMapper.selectAllLevKld(levKld,pageNum,pageSize);
    }

    /**
     * 2.通过一级查询所有二级知识点分类
     * @return
     */
    @Override
    public Page<SecKld> selectAllSecKld(SecKld secKld, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return levKldMapper.selectAllSecKld(secKld,pageNum,pageSize);
    }

    /**
     * 3.新增一级知识点分类
     * @param levKld
     * @return
     */
    @Override
    public int levKldInsert(LevKld levKld) {
        return levKldMapper.levKldInsert(levKld);
    }

    /**
     * 4.新增一级知识点分类
     * @param secKld
     * @return
     */
    @Override
    public int secKldInsert(SecKld secKld) {
        return levKldMapper.secKldInsert(secKld);
    }

    /**
     * 5.更新一级知识点分类
     * @param levKld
     * @return
     */
    @Override
    public int levKldUpdate(LevKld levKld) {
        return levKldMapper.levKldUpdate(levKld);
    }

    /**
     * 6.更新二级知识点分类
     * @param secKld
     * @return
     */
    @Override
    public int secKldUpdate(SecKld secKld) {
        return levKldMapper.secKldUpdate(secKld);
    }

    /**
     * 7.删除一级知识点分类(暂时不能删除，会违反多个表约束)
     * @param levKld
     * @return
     */
    @Override
    public int levKldDelete(LevKld levKld) {
        return levKldMapper.levKldDelete(levKld);
    }

    /**
     * 8.删除二级知识点分类
     * @param secKld
     * @return
     */
    @Override
    public int secKldDelete(SecKld secKld) {
        return levKldMapper.secKldDelete(secKld);
    }
}
